package com.hm.ibsm.util;

import org.springframework.data.redis.core.RedisTemplate;

import com.hm.ibsm.auto.ManageProperties;

/**
 * @author shishun.wang
 * @date 2017年2月22日 下午4:26:38
 * @version 1.0
 * @param <T>
 * @describe
 */
public final class RedisUtilFactory {

	private RedisTemplate<String, Object> redisTemplate;

	private ManageProperties manageProperties;

	public RedisUtilFactory(RedisTemplate<String, Object> redisTemplate, ManageProperties manageProperties) {
		this.redisTemplate = redisTemplate;
		this.manageProperties = manageProperties;
	}

	public long sequenceNumber() {
		return redisTemplate.opsForValue().increment(manageProperties.getRedisConfig().getSequenceNumberKey(), 1);
	}

	public long sequenceNumber(String sequenceNumber, int stepLength) {
		return redisTemplate.opsForValue().increment(sequenceNumber, stepLength);
	}

}
